<<<<<<< HEAD
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * 额度申请
 * @author chenhuan
 *
 */
class Amount extends MY_Controller {
	function __construct(){
		parent::__construct();
		exit;
		
		/** 登陆验证 */
		$user = $this->session->userdata('rsh_user');
		if(!isset($user['user_id'])){
			$str = $_SERVER['REQUEST_URI'];
			$this->js->go('/login.html');
		}elseif(!$user['user_id']){
			$this->js->go('/login.html');
		}
		
		$this->tab = 'user';
		$this->sub = 'borrow';
	}
	
	/**
	 * 额度申请
	 */
	function index(){
		$this->load->model('User_amount_model');
		$user = $this->session->userdata('rsh_user');
		$data['where']['user_id'] = $user['user_id'];
		
		$vdata = $this->get_user_info('','amount');
		
		$a_vdata = $this->User_amount_model->get_amount_apply_list($data);		
		$vdata['amount_apply_list'] = $a_vdata['amount_apply_list'];
		
		
		$vdata['title'] 						= "额度申请".' - '.CON_KEYWORDS;
		$vdata['types'] = $this->User_amount_model->arrays("amount_type");
		$this->load->view('/user/user_amount', $vdata);
	}
	
	/**
	 * 提交申请
	 */
	function apply(){
		$ret = array(
			'msg' => '',
			'url' => '',
		);
		$user = $this->session->userdata('rsh_user');
		$this->load->model('User_model');
		$this->load->model('Borrow_model');
		$user_obj = $this->User_model->get_all_by_id($user['user_id']);
		if($user_obj['real_status'] == 0){
			$ret['msg'] = '请先实名认证';
		}
		/*if($user_obj['avatar_status'] == 0){
			$this->js->alert("请先实名认证");
			$this->js->go("/user/realname");
		}*/
		if($user_obj['email_status'] != 1){
			$ret['msg'] = "请先Email认证";
		}
		if($user_obj['phone_status'] != 1){
			$ret['msg'] = "请先手机认证";
		}
		if($ret['msg']){
			echo json_encode($ret);exit;
		}
		
		$account  	= $this->input->post('account');
		$remark  	= $this->input->post('remark');
		$this->load->model('User_amount_model');
		
		$user_amount_obj = $this->User_amount_model->get_last_user_amount_apply(array('where'=>array('user_id'=>$user['user_id'])));
		if(isset($user_amount_obj)){
			if(isset($user_amount_obj['fstatus']) && $user_amount_obj['fstatus'] == 0){
				$ret['msg'] = '您还有正在审核中的额度申请。';	
			}
		}
		if($ret['msg']){
			echo json_encode($ret);exit;
		}
		$amount = $this->User_amount_model->get_one($user['user_id']);
		
		$data['user_id'] 	= $user['user_id'];
		$data['add_time'] 	= time();
		$data['addip'] 		= $this->input->ip_address();
		$data['ftype'] 		= AMOUNT_CREDIT;//信用额度
		$data['account'] 	= $account;
		$data['remark'] 	= $remark;
		$data["account_old"]= isset($amount['credit'])?$amount['credit']:0;
		$this->User_amount_model->add_amount_apply($data);
		$ret['msg'] = '额度申请成功，等待审核。';
		$ret['url'] = '/amount/index/index.html';
		echo json_encode($ret);exit;
	}
	
=======
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * 额度申请
 * @author chenhuan
 *
 */
class Amount extends MY_Controller {
    function __construct(){
		parent::__construct();
		exit;
		
		/** 登陆验证 */
		$user = $this->session->userdata('rsh_user');
		if(!isset($user['user_id'])){
			$str = $_SERVER['REQUEST_URI'];
			$this->js->go('/login.html');
		}elseif(!$user['user_id']){
			$this->js->go('/login.html');
		}
		
		$this->tab = 'user';
		$this->sub = 'borrow';
	}
	
	/**
	 * 额度申请
	 */
	function index(){
		$this->load->model('User_amount_model');
		$user = $this->session->userdata('rsh_user');
		$data['where']['user_id'] = $user['user_id'];
		
		$vdata = $this->get_user_info('','amount');
		
		$a_vdata = $this->User_amount_model->get_amount_apply_list($data);		
		$vdata['amount_apply_list'] = $a_vdata['amount_apply_list'];
		
		
		$vdata['title'] 						= "额度申请".' - '.CON_KEYWORDS;
		$vdata['types'] = $this->User_amount_model->arrays("amount_type");
		$this->load->view('/user/user_amount', $vdata);
	}
	
	/**
	 * 提交申请
	 */
	function apply(){
		$ret = array(
			'msg' => '',
			'url' => '',
		);
		$user = $this->session->userdata('rsh_user');
		$this->load->model('User_model');
		$this->load->model('Borrow_model');
		$user_obj = $this->User_model->get_all_by_id($user['user_id']);
		if($user_obj['real_status'] == 0){
			$ret['msg'] = '请先实名认证';
		}
		/*if($user_obj['avatar_status'] == 0){
			$this->js->alert("请先实名认证");
			$this->js->go("/user/realname");
		}*/
		if($user_obj['email_status'] != 1){
			$ret['msg'] = "请先Email认证";
		}
		if($user_obj['phone_status'] != 1){
			$ret['msg'] = "请先手机认证";
		}
		if($ret['msg']){
			echo json_encode($ret);exit;
		}
		
		$account  	= $this->input->post('account');
		$remark  	= $this->input->post('remark');
		$this->load->model('User_amount_model');
		
		$user_amount_obj = $this->User_amount_model->get_last_user_amount_apply(array('where'=>array('user_id'=>$user['user_id'])));
		if(isset($user_amount_obj)){
			if(isset($user_amount_obj['fstatus']) && $user_amount_obj['fstatus'] == 0){
				$ret['msg'] = '您还有正在审核中的额度申请。';	
			}
		}
		if($ret['msg']){
			echo json_encode($ret);exit;
		}
		$amount = $this->User_amount_model->get_one($user['user_id']);
		
		$data['user_id'] 	= $user['user_id'];
		$data['add_time'] 	= time();
		$data['addip'] 		= $this->input->ip_address();
		$data['ftype'] 		= AMOUNT_CREDIT;//信用额度
		$data['account'] 	= $account;
		$data['remark'] 	= $remark;
		$data["account_old"]= isset($amount['credit'])?$amount['credit']:0;
		$this->User_amount_model->add_amount_apply($data);
		$ret['msg'] = '额度申请成功，等待审核。';
		$ret['url'] = '/amount/index/index.html';
		echo json_encode($ret);exit;
	}
	
>>>>>>> d47623b610d79a4eeb489500830c00d70933f414
}